package com.example.keshe0337.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.keshe0337.entity.Rent;
import com.example.keshe0337.entity.User;

import java.util.List;

@Dao
public interface RentDao {
    @Insert
    long insertRent(Rent rent);

    @Delete
    void deleteRent(Rent rent);

    @Update
    void updateRent(Rent rent);

    @Query("SELECT * FROM rent WHERE id = :id")
    Rent getRentById(Long id);

    @Query("SELECT * FROM rent WHERE user_id = :uId")
    List<Rent> getRentByUId(Long uId);

    @Query("SELECT * FROM rent WHERE user_id = :uId AND space_num = :num")
    List<Rent> getRentByUIdAndSum(Long uId,String num);

    @Query("SELECT * FROM rent")
    List<Rent> getAllRents();

    @Query("SELECT * FROM rent WHERE space_num = :num")
    Rent getRentBySum(String num);

}
